package code.google.jcontainer.support.intercept;

/**
 * Interface to indicate that this component is interceptable,
 * Component want to use @Intercept should implement this class
 * 
 * Here is a example:
 * \@SimpleBean(name = "InterceptableTestBean")
 * public class InterceptableTestBean implements Interceptable {
 *
 * public void beforeMethod(InterceptContext interceptContext) throws Exception {
 *       System.out.println("beforeMethod: " + interceptContext.getMethod().getName());
 *       interceptContext.setParameters(new Object[]{"World"});
 *   }
 *
 *   public void afterMethod(InterceptContext interceptContext) throws Exception {
 *       System.out.println("afterMethod: " + interceptContext.getMethod().getName());
 *       interceptContext.setResult("Java");
 *   }
 *
 *   \@Intercept
 *   public String echo(String str){
 *       return str;
 *   }
 *
 * }
 *
 * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
 */
public interface Interceptable {

    /**
     * anything want to do before method
     * @param interceptContext Intercept context, contains context resources
     * @throws Exception
     */
    void beforeMethod(InterceptContext interceptContext) throws Exception;

    /**
     * anything want to do after method
     * @param interceptContext Intercept context, contains context resources
     * @throws Exception
     */
    void afterMethod(InterceptContext interceptContext) throws Exception;

}
